package oocl.ita.eordering.listener;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class ConfigListener implements ServletContextListener {
	private static Properties prop = new Properties();

	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		try {
			prop.load(new FileInputStream(ConfigListener.class.getClassLoader().getResource("PicServerConfig.properties").getPath()));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String myPicServer = prop.getProperty("myPicServer");
//		String myPicServer = "http://10.222.232.145:8080/imgs/";
		ServletContext app=arg0.getServletContext();
		app.setAttribute("myPicServer", myPicServer);
	}

}
